import time
import allure
import pytest
from selenium.webdriver.common.by import By
from pytest00.tpshop.page.page import Home, Zhuce, Login
from pytest00.tpshop.tpdata import login_pam, resu
from pytest00.tpshop.util import ass_text, err, ass, Driver, sum1


@allure.epic("tp前台项目")
@allure.feature("tp前台项目test.py模块哦")
class Test_zhuce:
    def setup_class(self):
        err(Home.click_zhuce)
    @allure.severity(allure.severity_level.BLOCKER)
    @allure.story("用例描述哦：tp前台项目，验证用户注册")
    @allure.testcase("http://localhost/index.php/Admin/Index/index")
    def test_zhuce(self):
        err(Zhuce().zhuce,"16620879439",'12345678')
        time.sleep(1)
        a=By.CSS_SELECTOR,'[class="layui-layer-content layui-layer-padding"]'
        te=err(ass_text,a)
        ass(te, '请用手机号或邮箱注册',"16620879439",'12345678')
    def teardown_class(self):
        Driver.quit_driver()

class Test_login():
    def setup_class(self):
        err(Home.click_login)
    @pytest.mark.parametrize("count",login_pam)
    @allure.severity(allure.severity_level.BLOCKER)
    #@pytest.mark.skip("")
    @pytest.mark.parametrize("pss", login_pam)
    @allure.story("用例描述哦：tp前台项目，验证用户登录")
    @allure.testcase("http://localhost/index.php/Admin/Index/index")
    def test_login(self, count, pss):
        err(Login().login, count, pss)
        text_ele=By.CSS_SELECTOR,'[class="layui-layer-content layui-layer-padding"]'
        te = err(ass_text, text_ele)#实际结果
        result= err(resu,count, pss)#预期结果
        ass(te,result,count, pss)
        driver = Driver.get_driver()
        driver.refresh()
    def teardown_class(self):
        Driver.quit_driver()
        sum1()


